package mapper.view;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import pojo.view.MRecord;

import java.sql.Timestamp;
import java.util.List;

public interface MRecordViewMapper {
    @Select("SELECT * FROM manager_record_view WHERE " +
            "floor_name=#{floor_name}" +
            "AND number=#{number}" +
            "AND reserve_time=#{reserve_time}")
    MRecord query(@Param("floor_name") String floor_name,
                  @Param("number") int number,
                  @Param("reserve_time") Timestamp reserve_time);

    @Select("SELECT * FROM manager_record_view")
    List<MRecord> queryAll();

    @Select("SELECT * FROM manager_record_view WHERE cancel_flag = 0 AND start_time IS NULL")
    List<MRecord> getUnUsed();

    @Select("SELECT * FROM manager_record_view WHERE cancel_flag = 0 AND start_time IS NOT NULL AND end_time IS NULL")
    List<MRecord> getInUse();

    @Select("SELECT * FROM manager_record_view WHERE cancel_flag = 1 OR (cancel_flag = 0 AND end_time IS NOT NULL)")
    List<MRecord> getCompleted();
}
